﻿using System.IO;
using System.Text;

namespace Gmantis.Imaging
{
    internal class EndianReader : BinaryReader
    {
        public EndianReader(Stream stream)
            : base(stream)
        {
        }

        public EndianReader(Stream stream, Encoding encoding)
            : base(stream, encoding)
        {
        }

        public int ReadInt32BigEndian()
        {
            return (int)this.ReadUInt32BigEndian();
        }

        public long ReadInt64BigEndian()
        {
            return (long)this.ReadUInt64BigEndian();
        }

        public uint ReadUInt32BigEndian()
        {
            byte[] buffer = this.ReadBytes(4);
            return (uint)(((buffer[3] | (buffer[2] << 8)) | (buffer[1] << 0x10)) | (buffer[0] << 0x18));
        }

        public ulong ReadUInt64BigEndian()
        {
            uint num = this.ReadUInt32BigEndian();
            uint num2 = this.ReadUInt32BigEndian();
            return ((num << 0x20) | num2);
        }
    }
}
